package com.study.a18choujiangxiang;

import java.util.ArrayList;
import java.util.Collections;

public class MyThread extends Thread{

   ArrayList<Integer> list;

   public MyThread(ArrayList<Integer> list) {
       this.list = list;
   }

   @Override
   public void run() {
       while(true){
           synchronized (MyThread.class){
               if(list.isEmpty()){
                   break;
               }else{
               Collections.shuffle(list);
               int prize=list.remove(0);
                   System.out.println(getName()+"产生"+prize+"奖金");
               }
           }
           try {
               Thread.sleep(10);
           } catch (InterruptedException e) {
               throw new RuntimeException(e);
           }

       }
   }


}
